package persistencia;

import modelo.Tarjeta;
import java.sql.*;

public class AdmPersTarjeta 
{
	private static AdmPersTarjeta instancia;
	
	public static AdmPersTarjeta getInstancia()
	{
		if (instancia == null)
			instancia = new AdmPersTarjeta();
		return instancia;
	}//singleton
	
	
	public Tarjeta select(String nro)
	{
		Tarjeta t = null;
		Connection con = PoolConnection.getPoolConnection().getConnection();
		try
		{
			PreparedStatement ps = con.prepareStatement("select * from banco.dbo.tarjetas where nro = ?");
			ps.setString(1,nro);
			
			ResultSet rs = ps.executeQuery();
			while (rs.next())
			{
				t = new Tarjeta (nro,rs.getString("tit"));
			}
			
			PoolConnection.getPoolConnection().realeaseConnection(con);
			return t;
		}
		catch(Exception e)
		{
			System.out.println("Error en select tarjeta");
			return t;
		}
	}
}
